import {
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
  DeleteDateColumn,
} from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';

/**
 * 基础实体类
 * 包含通用字段：id、创建时间、更新时间、删除时间
 */
export abstract class BaseEntity {
  @ApiProperty({ description: '主键ID' })
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty({ description: '创建时间' })
  @CreateDateColumn({
    type: 'datetime',
    comment: '创建时间',
  })
  createdAt: Date;

  @ApiProperty({ description: '更新时间' })
  @UpdateDateColumn({
    type: 'datetime',
    comment: '更新时间',
  })
  updatedAt: Date;

  @ApiProperty({ description: '删除时间' })
  @DeleteDateColumn({
    type: 'datetime',
    nullable: true,
    comment: '删除时间',
  })
  deletedAt?: Date;
}